#ifndef __SILOACTOR_H__
#define __SILOACTOR_H__

#include <math.h>
#include "actor.h"

class SiloActor : public Actor
{
public:
  SiloActor(f32 x, f32 y)
    : Actor(), state(SI_NULL), x(x), y(y), tx(x), ty(y-1), theta(0),
      ammo(3), maxammo(3), health(1), maxhealth(1) {};

  void markKilled() {state = SI_DEAD;}
  void aimAt(f32 targetx, f32 targety) {tx = targetx; ty = targety;}
  bool canLaunch() {return state == SI_ALIVE && ammo > 1 && health > 0;}
  void directHit();
  void splashHit();
  f32 getHealthPct() {return state == SI_ALIVE ? health/maxhealth : 0;}
  f32 getAmmoPct() {return state == SI_ALIVE ? ammo/maxammo : 0;}
  void fireMissile() {ammo -= 1;}

public:
  void activate();
  void update();

  f32 getX();
  f32 getY();
  f32 getR() {return SILOR;}
  f32 getRotation();// {return theta*180.0/M_PI;}
  int getT() {return 0;}
  bool isActive() {return state != SI_NULL;}

public:
  Sprite healthbar;
  Sprite ammobar;

protected:
  const static f32 SILOR = 1.0;
  const static f32 BASERAD = 1.0;
  const static f32 AMMOREGEN = .05;
  const static f32 SPLASHDMG = .01;
  const static f32 DIRECTDMG = .2;
  const static f32 HEALTHREGENSLOW = .001;
  const static f32 AMMOREGENSLOW = .01;

  enum {
    SI_NULL,
    SI_ALIVE,
    SI_DEAD
  } state;

  f32 x,y;
  f32 tx, ty;
  f32 theta;
  
  f32 ammo;
  f32 maxammo;
  f32 health;
  f32 maxhealth;
};

#endif
